#!/bin/bash

# convenience script to run liquibase with suitable Zanata settings
# see http://liquibase.org/manual/command_line

# If you need mysql/slf4j jars: yum install mysql-connector-java slf4j

SCRIPT_PATH=`dirname ${BASH_SOURCE[0]}`
war=$SCRIPT_PATH/..

classpath=\
$(echo \
   $war/WEB-INF/classes/ \
   /usr/share/java/mysql-connector-java.jar \
   /usr/share/java/slf4j/simple.jar \
   /usr/share/java/slf4j/api.jar \
   $war/WEB-INF/lib/*.jar \
 | sed 's/ /:/g')

# slf4j simple.jar needs to be before api.jar due to
# https://bugzilla.redhat.com/show_bug.cgi?id=828644

if [ -r liquibase.properties ]; then
  defs=
else
  defs=--defaultsFile=$HOME/.config/liquibase.properties
fi

java \
-jar $war/WEB-INF/lib/liquibase-core*.jar \
--classpath $classpath \
--changeLogFile db/db.changelog.xml \
$defs \
"$@"

exit 0




sample of liquibase.properties (put in $HOME/.config/, or current dir):

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/zanata?characterEncoding=UTF-8
username=root
password=rootpassword
